﻿<phone:PhoneApplicationPage
    x:Class="OsmerFvg.Views.WebCamsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <Style TargetType="ListBox" x:Name="HorizontalListBox">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Horizontal" CanHorizontallyScroll="True" CanVerticallyScroll="False"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="Web Cams" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" />

        <StackPanel Grid.Row="1" Margin="0,0,0,0">
            <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto"  ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <ListBox Height="650" Margin="12,6,12,0" ItemsSource="{Binding WebCamsList}" SelectedItem="{Binding SelectedWebCam,Mode=TwoWay}" SelectionMode="Single">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel Height="650" Orientation="Vertical" ItemWidth="200" ItemHeight="215"></toolkit:WrapPanel>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <Border Width="192" Height="144" BorderThickness="2" BorderBrush="{StaticResource PhoneForegroundBrush}">
                                    <Image Stretch="Uniform" Width="192" Height="144" Source="{Binding Path=WebCamUri}" >
                                        <i:Interaction.Triggers>
                                            <i:EventTrigger EventName="Tap">
                                                <cal:ActionMessage MethodName="ZoomWebCamCommand" />
                                            </i:EventTrigger>
                                        </i:Interaction.Triggers>
                                    </Image>
                                </Border>
                                <TextBlock Text="{Binding Path=WebCamName}" Width="192" Height="40" TextAlignment="Center"  />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </ScrollViewer>

        </StackPanel>
    </Grid>


</phone:PhoneApplicationPage>